<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
<!--    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>-->
    <script src="js/echart.min.js"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="main" style="width: 600px;height:400px;"></div>

<script type="text/javascript">

    // data 的结构:
    // {
    //     categories: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"],
    //     values: [5, 20, 36, 10, 10, 20]
    // }

    var data1 =   {
         categories: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"],
         values: [5, 20, 36, 10, 10, 20]
     }

    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    // 显示标题，图例和空的坐标轴
    myChart.setOption({
        title: {
            text: '异步数据加载示例'
        },
        tooltip: {},
        legend: {
            data: ['销量']
        },
        xAxis: {
            data: []
        },
        yAxis: {},
        series: [
            {
                name: '销量',
                type: 'bar',
                data: []
            }
        ]
    });

    // 异步加载数据
    $.get('/echart.html').done(function(data) {
        // 填入数据
        myChart.setOption({
            xAxis: {
                data: data1.categories
            },
            series: [
                {
                    // 根据名字对应到相应的系列
                    name: '销量',
                    data: data1.values
                }
            ]
        });
    });

</script>
</body>
</html>